home *** CD-ROM | disk | FTP | other *** search
/ 9-Digit Zip Code Directory / 9-Digit Zip Code Directory (American Business Information) (ABIZIP-12).ISO / z4src.zip / CLCHILD.CPP < prev    next >
C/C++ Source or Header  |  1993-09-02  |  9KB  |  275 lines

  1. //----------------------------------------------------------------------------
  2. //                            MODULE DESCRIPTION
  3. //
  4. //  Module:    clchild.cpp
  5. //   Title:    Base library
  6. //  Notice:    John M. Weeder
  7. //                 Copyright (c) 1993. All rights reserved.
  8. //             This module contains proprietary information and should be 
  9. //                treated as confidential.
  10. //
  11. //----------------------------------------------------------------------------
  12. //                           MAINTENANCE HISTORY
  13. //
  14. // $Workfile$
  15. // $Revision$
  16. //   $Author$
  17. //     $Date$
  18. //      $Log$    
  19. //
  20. //----------------------------------------------------------------------------
  21. //                             MODULE NARRATIVE
  22. //
  23. //    This module contains code for the class CL_CHILD.
  24. //
  25. //    The code in this module may be written in C++ or C.
  26. //
  27. //    This module is portable to:
  28. //        DOS 3.X+
  29. //        MS Windows 3.X+
  30. //        MS Windows NT
  31. //        OS/2 2.X+
  32. //        OS/2 2.0 PM
  33. //
  34. //    The following compilers are supported:
  35. //        MSC 6.0A
  36. //        MSC/C++ 7.0
  37. //        Borland C++ 3.1 for DOS
  38. //        Borland C++ 1.0 for OS/2 2.X
  39. //
  40. //----------------------------------------------------------------------------
  41. #include <class.hpp>
  42.  
  43.  
  44. //----------------------------------------------------------------------------
  45. //   Description:    Default constructor
  46. //    Parameters:
  47. //       Returns:    
  48. //----------------------------------------------------------------------------
  49. FN_M CL_CHILD::CL_CHILD()
  50. {
  51.     CL_CHILD::Initialize(CL_INIT_CLASS);
  52. }
  53.  
  54.  
  55. //----------------------------------------------------------------------------
  56. //   Description:    Copy constructor
  57. //    Parameters:    rccl_child        Reference to object to copy.
  58. //       Returns:    
  59. //----------------------------------------------------------------------------
  60. FN_M CL_CHILD::CL_CHILD(RCCL_CHILD rccl_child)
  61. {
  62.     CL_CHILD::Initialize(CL_INIT_CLASS);
  63.     *this = rccl_child;
  64. }
  65.  
  66.  
  67. //----------------------------------------------------------------------------
  68. //   Description:    Destructor
  69. //    Parameters:
  70. //       Returns:    
  71. //----------------------------------------------------------------------------
  72. FN_M CL_CHILD::~CL_CHILD()
  73. {
  74.     CL_CHILD::Destroy(FALSE);
  75. }
  76.  
  77.  
  78. //----------------------------------------------------------------------------
  79. //   Description:    Destroy object. Free any resources used by object.
  80. //                          Normally called by destructor.
  81. //                        Should allow multiple calls from various classes.
  82. //                        A class should almost always re-init its variables when 
  83. //                        it is destroyed to prevent accidents.
  84. //    Parameters:    fDestroyAll        Destroy parents also?
  85. //                                            Default is TRUE.
  86. //       Returns:    TRUE if successful.
  87. //----------------------------------------------------------------------------
  88. BOOL FN_M CL_CHILD::Destroy(BOOL fDestroyAll)
  89. {
  90.     // Destroy object specific stuff
  91.     CL_CHILD::Initialize(CL_INIT_CLASS_VARS);
  92.     if (fDestroyAll)                            // Destroy parent.
  93.         CL_CHILD_PARENT::Destroy(fDestroyAll);
  94.     return TRUE;
  95. }
  96.  
  97.  
  98. //----------------------------------------------------------------------------
  99. //   Description:    Initialize object. 
  100. //                          Normally called by constructor.
  101. //                        Should allow multiple calls from various classes.
  102. //    Parameters:    sInit        Initialization code. May be one of the following:
  103. //                                        CL_INIT_CLASS            Reset class variables and
  104. //                                                                    and dynamic allocations for
  105. //                                                                    this class only.
  106. //                                        CL_INIT_CLASS_VARS    Reset class variables for
  107. //                                                                    this class only.
  108. //                                        CL_INIT_VARS            Reset class variables for
  109. //                                                                    this class only.
  110. //                                        CL_INIT_ALL                Initialize class and all 
  111. //                                                                    parent class, including
  112. //                                                                    dynamic memory allocation.
  113. //                                    Default is CL_INIT_ALL
  114. //       Returns:    TRUE if successful.
  115. //----------------------------------------------------------------------------
  116. BOOL FN_M CL_CHILD::Initialize(SHORT sInit)
  117. {
  118.     if (sInit == CL_INIT_VARS || sInit == CL_INIT_ALL)
  119.         CL_CHILD_PARENT::Initialize(sInit);
  120.  
  121.     // Initialize object specific stuff like variables
  122.  
  123.     if (sInit == CL_INIT_CLASS_VARS || sInit == CL_INIT_VARS)
  124.         return TRUE;
  125.  
  126.     // Initialize any dynamic memory allocation or files, etc...
  127.     return TRUE;
  128. }
  129.  
  130.  
  131. //----------------------------------------------------------------------------
  132. //   Description:    Check if object is in error state.
  133. //                          IsValid() && IsError() MUST NOT BE DEPENDENT ON ONE ANOTHER.
  134. //    Parameters:
  135. //       Returns:    TRUE if in error state.
  136. //----------------------------------------------------------------------------
  137. BOOL FN_M CL_CHILD::IsError() const
  138. {
  139.     return CL_CHILD_PARENT::IsError();
  140. }
  141.  
  142.  
  143. //----------------------------------------------------------------------------
  144. //   Description:    Check if object is valid
  145. //                          IsValid() && IsError() MUST NOT BE DEPENDENT ON ONE ANOTHER.
  146. //    Parameters:
  147. //       Returns:    TRUE if valid
  148. //----------------------------------------------------------------------------
  149. BOOL FN_M CL_CHILD::IsValid() const
  150. {
  151.     return CL_CHILD_PARENT::IsValid();
  152. }
  153.  
  154.  
  155. //----------------------------------------------------------------------------
  156. //   Description:    Assignment operator
  157. //                          NOTE: Don't copy object into self
  158. //    Parameters:    rccl_child        Reference to right value.
  159. //       Returns:    Reference to new object.
  160. //----------------------------------------------------------------------------
  161. RCCL_CHILD FN_M CL_CHILD::operator=(RCCL_CHILD rccl_child)
  162. {
  163.     if (this != &rccl_child)
  164.         {
  165.         Invalid("CL_CHILD::operator=");
  166.         }
  167.     return (RCCL_CHILD)*this;
  168. }
  169.  
  170.  
  171. //----------------------------------------------------------------------------
  172. //   Description:    Retrieve object from persistent storage
  173. //    Parameters:    pcsz        Name of object.
  174. //                        pcszSub    Sub-name of object.
  175. //                                    The first character of the name should be '~'.
  176. //                                    If NULL, no sub name is available.
  177. //                                    Default is NULL
  178. //       Returns:    TRUE if successful.
  179. //----------------------------------------------------------------------------
  180. BOOL FN_M CL_CHILD::Retrieve(PCSZ pcsz, PCSZ pcszSub)
  181. {
  182.     NOTUSED(pcsz);
  183.     NOTUSED(pcszSub);
  184.     Invalid("CL_CHILD::Retrieve");
  185.     return FALSE;
  186. }
  187.  
  188.  
  189. //----------------------------------------------------------------------------
  190. //   Description:    Store object to persistent storage
  191. //    Parameters:    pcsz        Name of object.
  192. //                        pcszSub    Sub-name of object.
  193. //                                    The first character of the name should be '~'.
  194. //                                    If NULL, no sub name is available.
  195. //                                    Default is NULL
  196. //       Returns:    TRUE if successful.
  197. //----------------------------------------------------------------------------
  198. BOOL FN_M CL_CHILD::Store(PCSZ pcsz, PCSZ pcszSub)
  199. {
  200.     NOTUSED(pcsz);
  201.     NOTUSED(pcszSub);
  202.     Invalid("CL_CHILD::Store");
  203.     return FALSE;
  204. }
  205.  
  206.  
  207. //----------------------------------------------------------------------------
  208. //   Description:    Print object value to debugging output.
  209. //    Parameters:    pccl_child        Pointer to dynamic object. 
  210. //                                    If NULL, static data elements are printed.
  211. //                                    Default is NULL.
  212. //                        pcsz        Name of object.
  213. //                                    If NULL, no name is displayed.
  214. //                                    Default is NULL.
  215. //                        cLevel    Display level. 
  216. //                                    Default is zero.
  217. //       Returns:
  218. //----------------------------------------------------------------------------
  219. #if COMPILE_DEBUG
  220. VOID FN_M CL_CHILD::Print(PCCL_CHILD pccl_child, PCSZ pcsz, SIZET cLevel)
  221. {
  222. #if COMPILE_TEST
  223.     OutputL(cLevel, "CL_CHILD%s%s", (pcsz?"::":""), (pcsz?pcsz:""));
  224.     cLevel++;
  225.     if (pccl_child)
  226.         {
  227.         Output(" <%p>\n", pccl_child);
  228.         if(!pccl_child->IsError())
  229.             {
  230. //            OutputL(cLevel, " = %d\n", pccl_child->);
  231.             }
  232.         }
  233.     else
  234.         Output(" <NULL>\n");
  235.     CL_CHILD_PARENT::Print((CL_CHILD_PARENT _FAR_ *)pccl_child, pcsz, cLevel);
  236.     return ;
  237. #else
  238.     NOTUSED(cLevel);
  239.     NOTUSED(pccl_child);
  240.     NOTUSED(pcsz);
  241.     return ;
  242. #endif
  243. }
  244. #endif
  245.  
  246.  
  247. //----------------------------------------------------------------------------
  248. //   Description:    Run standard test suite on object.
  249. //    Parameters:    sTest        Test to run.
  250. //                                    If 0, run default tests.
  251. //                                    Default is 0.
  252. //       Returns:    TRUE if successful.
  253. //----------------------------------------------------------------------------
  254. #if COMPILE_DEBUG
  255. BOOL FN_M CL_CHILD::Test(SHORT sTest)
  256. {
  257. #if COMPILE_TEST
  258.     if (sTest == 1)                            // Test 1 is always a test of storage
  259.         {
  260.         CL_CHILD cl_child;
  261.         cl_child.Store("CL_CHILD");
  262.         cl_child.Retrieve("CL_CHILD");
  263.         CL_CHILD::Print(&cl_child);
  264.         }
  265.     return TRUE;
  266. #else
  267.     NOTUSED(sTest);
  268.     return TRUE;
  269. #endif
  270. }
  271. #endif
  272. //----------------------------------------------------------------------------
  273. //------------------------------- End of File --------------------------------
  274. //----------------------------------------------------------------------------
  275.